package com.question.business.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.question.business.user.entity.UserOrg;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户机构Mapper接口
 *
 * @author star
 * @since 2023-09-15
 */
@Mapper
public interface UserOrgMapper extends BaseMapper<UserOrg> {

    /**
     * 用户机构查询
     *
     * @param userId 用户ID
     * @return List<String> 响应参数
     */
    @Select("SELECT org_id FROM t_user_org WHERE user_id = #{userId}")
    List<String> queryOrgByUserId(String userId);

    /**
     * 机构用户查询
     *
     * @param orgId 机构ID
     * @return List<String> 响应参数
     */
    @Select("SELECT user_id FROM t_user_org WHERE org_id = #{orgId}")
    List<String> queryUserByOrgId(String orgId);

    /**
     * 根据用户ID删除机构
     *
     * @param userId 用户ID
     */
    @Delete("DELETE FROM t_user_org WHERE user_id = #{userId}")
    void deleteByUserId(String userId);

    /**
     * 根据机构ID删除用户
     *
     * @param orgId 机构ID
     */
    @Delete("DELETE FROM t_user_org WHERE org_id = #{orgId}")
    void deleteByOrgId(String orgId);
    
}